﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Xml.Serialization;

namespace MobileCarManager.MobileControls.Styles
{
  /// <summary>Implements the style data structure for a gradient.</summary>
  [Serializable]
  public class GradientStyle
  {
    /// <summary>Constructor.</summary>
    public GradientStyle()
    {
      Gradient = new List<Color>();
    }

    /// <summary>Returns a list of colors used for the gradient.</summary>
    [XmlIgnore]
    public List<Color> Gradient { get; set; }

    /// <summary>
    /// Returns a list of colors for the gradient in a serializable form. This property
    /// is used for serialization.
    /// </summary>
    [XmlArray("Gradient")]
    public List<string> SerializableGradient
    {
      get 
      {
        List<string> serializableGradient = new List<string>();
        foreach (Color color in Gradient)
        {
          serializableGradient.Add(StyleManager.SerializeColor(color));
        }
        return serializableGradient;
      }
      set
      {
        Gradient.Clear();
        foreach (string color in value)
        {
          Gradient.Add(StyleManager.DeserializeColor(color));
        }
      }
    }
  }
}
